﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GeckoPhotos.Models;
using System.Data.Objects;

namespace GeckoPhotos.Repository
{
    public class EFUserRepository : EFRepositoryBase<int, User>, IUserRepository
    {
        public EFUserRepository()
            : this(new DatabaseEntities())
        {
        }

        public EFUserRepository(DatabaseEntities context)
            : base(context.Users)
        {
        }

        public User SingleWithMessages(Func<User, bool> query)
        {
            return _objectSet
                .Include("UserMessages")
                .Include("UserMessages.Message")
                .Where(query)
                .Single();
        }
    }
}
